package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.ItemCatMapper;
import com.jt.pojo.ItemCat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemCatServiceImpl implements ItemCatService{

    @Autowired
    private ItemCatMapper itemCatMapper;


    @Override
    public List<ItemCat> getLeft() {
        List<ItemCat> list=itemCatMapper.selectList(new QueryWrapper<ItemCat>()
                .eq("parent_id", 0)
        );
        for(ItemCat itemCat:list){
            List<ItemCat> two=itemCatMapper.selectList(new QueryWrapper<ItemCat>()
                    .eq("parent_id", itemCat.getId())
            );
            itemCat.setChildren(two);
        }
        return list;
    }
}
